/**
 * @author 史鑫鑫
 * @description 社交相关接口合集
 * @date 2021-03-06
 * @modefied 史鑫鑫
 */
import request from '@/utils/request'

/**
 * 修改备注
 * @param {String} friendId 好友id
 * @param {String} friendRemark 备注
 */
export function modifyRemark (friendId, friendRemark) {
  return request({
    url: '/c/api/v2/contact/social/friend/remark',
    method: 'put',
    data: {
      friendId,
      friendRemark
    }
  })
}

/**
 * 删除好友
 * @param {String} friendId 好友id
 */
export function friendDelete (friendId) {
  return request({
    url: `/c/api/v2/contact/social/friend/${friendId}`,
    method: 'delete'
  })
}

/**
 * 按照关键字查询好友
 * @param {String} keyword 关键字
 */
export function friendsSearch (keyword) {
  return request({
    url: '/c/api/v2/contact/social/friends/search',
    method: 'get',
    params: {
      keyword
    }
  })
}

/**
 * 申请添加好友
 * @param {String} friendId 好友id
 * @param {String} organizationId 分组id
 * @param {String} remark  备注信息
 */
export function applyFriend (friendId, organizationId, remark) {
  return request({
    url: '/c/api/v2/contact/social/friend/application',
    method: 'post',
    data: {
      friendId,
      organizationId,
      remark
    }
  })
}

/**
 * 申请通过，添加好友
 * @param {String} message key
 * @param {String} organizationId 分组id
 */
export function addFriend (message, organizationId) {
  return request({
    url: '/c/api/v2/contact/social/friend/pass',
    method: 'post',
    data: {
      message,
      organizationId
    }
  })
}

/**
 * 拒绝好友申请
 * @param {String} message key
 */
export function refuseFriend (message) {
  return request({
    url: `/c/api/v2/contact/social/friend/refuse/${message}`,
    method: 'post'
  })
}

/**
 * 根据关键字查询群组
 * @param {String} keyword 关键字
 */
export function groupSearch (keyword) {
  return request({
    url: '/c/api/v2/contact/social/groups/search',
    method: 'get',
    params: {
      keyword
    }
  })
}

/**
 * 申请加入群
 * @param {String} groupId 群id
 * @param {String} remark 备注信息
 */
export function applyGroup (groupId, remark) {
  return request({
    url: '/c/api/v2/contact/social/group/application',
    method: 'post',
    params: {
      groupId,
      remark
    }
  })
}
/**
 * 同意申请入群
 * @param {String} message key
 */
export function groupPass (message) {
  return request({
    url: `/c/api/v2/contact/social/group/pass/${message}`,
    method: 'post'
  })
}

/**
 * 拒绝入群申请
 * @param {String} message key
 */
export function groupRefuse (message) {
  return request({
    url: `/c/api/v2/contact/social/group/refuse/${message}`,
    method: 'post'
  })
}
